package com.boot.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * DESC: ElasticSearch配置类
 *
 * @author WangJie
 * @date Created in 2025-04-17 18:43
 */
@Configuration
public class ElasticSearchConfig {

    /**
     * DESC: 创建RestHighLevelClient实例
     * PS：在application.properties中配置spring.data.elasticsearch.cluster-nodes=127.0.0.1:9200
     * @return RestHighLevelClient实例
     **/
    @Bean
    public RestHighLevelClient restHighLevelClient() {
        return new RestHighLevelClient(RestClient.builder(new HttpHost("127.0.0.1", 9200, "http")));
    }
}
